#!/bin/ksh
#--------------------------------------------------------------
# Script Name : FTP the backupSet to aybq74 
# Created by  : hartlen 
#         on  : 2009.09.15
# Updated by  : 
#         on  : 
# Parameters  : $1=FTP file
# Return Code : 0   = Normal End
# Comments    : 
#--------------------------------------------------------------
PATH=$PATH:/home/oracle/scripts ; export PATH
BKUP=/oracle/backup
BK_STATUS=/oracle/backup/log/BK_STATUS
FTP_STATUS=/oracle/backup/log/FTP_STATUS
MSG_LOG=/oracle/backup/log/joblog_`date +%Y%m`.log ;export MSG_LOG
JOBNAME=FTP          ; export JOBNAME
LOG=/tmp/FTP.log
DATE_FORMAT=`date +%Y%m%d`
case $1 in
"")
  ftpfile="*"
  ;;
*)
  ftpfile=$1
  ;;
esac

ftphostIP=192.168.2.11
ftpuser=monitor
ftppasswd=monitor
ftppath=/ybq74/usr99/backup/CRM_BAK

#----------------------------------------------------
# delete the yestoday ftp status log
#----------------------------------------------------
if [[ -f $FTP_STATUS ]]
then
  /bin/rm -f  $FTP_STATUS
  MSG_JOB I "Remove statuslog $FTP_STATUS"
  MSG_JOB I "Remove.sh maybe have error"
fi

MSG_JOB S

ftp -i -n $ftphostIP <<EOF  >$LOG 2>&1
user $ftpuser  $ftppasswd
bin
cd $ftppath 
lcd $BKUP
prompt off
prompt off
mput $ftpfile
bye
EOF

if [[ $? != 0 ]]
then
  MSG_JOB E 
  exit $? 
else
  MSG_JOB N 
  echo "Successfully" > $FTP_STATUS
 exit 0 
fi

